#ifndef wasutil_hpp
#define wasutil_hpp

#include <WinSock2.h>
#include <Windows.h>
#include <Audioclient.h>
#include <audiopolicy.h>
#include <mmdeviceapi.h>
#include <avrt.h>

#include "uigtk.hpp"
#include "libwifiparty/libwifiparty.hpp"
#include "party-protocol/party-protocol.hpp"

// REFERENCE_TIME time units per second and per millisecond
#define REFTIMES_PER_SEC  10000000
#define REFTIMES_PER_MILLISEC  10000


enum channel_ids {
    music=1,
    vocal=2,
};

struct coreinfo {
    Mixer<Trackreceiver>* trackMixer;
    Channel* music_channel, * vocal_channel;
    Trackreceiver* vocal_track, * music_track;
    Receiver* receiver;

    //HANDLE playCallbackThread;
    HANDLE hPlayCallbackEvent,hRecordCallbackEvent,hAppAudioCallbackEvent;
    IAudioClient* pPlayAudioClient,*pRecordAudioClient,*pAppAudioClient;
    IAudioRenderClient* pRenderClient;
    IAudioCaptureClient* pCaptureClient, *pAppAudioCaptureClient;
    UINT32 playBufferFrameCount, recordBufferFrameCount, appAudioBufferFrameCount;
    WAVEFORMATEX format;
};

DWORD WINAPI playCallbackHandler(LPVOID userdata);
DWORD WINAPI recordCallbackHandler(LPVOID userdata);
DWORD WINAPI appAudioCallbackHandler(LPVOID userdata);

void startAppAudio(struct coreinfo* ci);
void stopAppAudio(struct coreinfo* ci);

void startSinging(struct coreinfo* ci);
void stopSinging(struct coreinfo* ci);

void startPlaying(struct coreinfo* ci);

#endif

